package com.itheima.springbootwebtlias.filter;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

@Slf4j
// 3.配置过滤器路径，/* 表示拦截所有请求
//@WebFilter(urlPatterns = "/*")
// 1.自定义过滤器类，实现Filter接口
public class MyFilter implements Filter {

    // 2.重写过滤器方法
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        log.info("拦截请求.........");

        filterChain.doFilter(servletRequest, servletResponse);

        log.info("拦截响应.........");
    }

}
